package elven.d.web.future.hello;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import elven.d.common.log.LogFactory;

public class HelloFuture {
	
	private static final ExecutorService executorService = Executors.newFixedThreadPool(3);
	
	public String wangwuMessage(){
		return "密码是2";
	}
	
	private String lisi(final String message) throws Exception{
		Future<String> futureResult = executorService.submit(new Callable<String>() {
			@Override
			public String call() throws Exception {
				return new HelloFuture().wangwuMessage();
			}
		});
		return "好啊，等会给王五一个惊喜："+futureResult.get();
	}
	
	public String zhangsanFuture() throws Exception{
		Future<String> futureResult = executorService.submit(new Callable<String>() {
			@Override
			public String call() throws Exception {
				return new HelloFuture().wangwuMessage();
			}
		});
		LogFactory.d().info("王五正在去完成张三的交代");
		LogFactory.d().info(lisi("今天他生日"));
		return futureResult.get();
	}
	
	public static void main(String[] args) {
		
		try {
			HelloFuture helloFuture = new HelloFuture();
			LogFactory.d().info(helloFuture.zhangsanFuture());
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
}
